<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>消息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport"/>
    <meta content="yes" name="apple-mobile-web-app-capable"/>
    <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
    <meta content="telephone=no" name="format-detection"/>
    <link href="/js/plugins/message/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="/js/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/js/plugins/message/tab.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/message.css" />
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(function () {
            //获取user信息
            var user =  JSON.parse(sessionStorage.getItem("user"));
            var list;
            //发送请求查询系统消息(查询未读的)
            $.get("/messages/systemMessage",{brower:0}, function (data) {
                console.log(data);
                list=data.list;
                if(list.length>0){
                    //渲染数据
                    $(".tab-panel-item").renderValues(data,{
                        getHref:getHref
                    });

                   $.each(list,function (index,ele) {
                        //设置这条信息状态为已读状态
                        $.ajax({
                            type: "PUT",
                            url: "/messages/systemMessage/"+ele.id
                        });
                    });


                }else{
                    $("#noMessage").remove();
                    $(document).dialog({
                        titleText: "温馨提示",
                        content: "没有新消息了",
                        //onClosed弹框关闭之后执行
                        onClosed:function () {
                            //没有结果就返回上一级页面
                            window.history.go(-1);
                        }
                    });
                }
            });

        });
    </script>


</head>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col">
            <a href="/mine/message.html">
                <span><i class="fa fa-chevron-left" ></i></span>
            </a>
        </div>
        <div class="col"></div>
    </div>
</div>



<div class="aui-flexView">
    <section class="aui-scrollView">
        <div class="aui-tab" data-ydui-tab>
            <ul class="tab-nav">
                <ul class="tab-nav">
                    <li class="tab-nav-item tab-active">
                        <a href="javascript:;">最新消息</a>
                    </li>
                </ul>
            </ul>
            <div id="noMessage" class="">
                <div class="tab-panel-item tab-active">
                    <div class="tab-item" render-loop="list">
                        <!--render-key是指值从哪里来,render-fun是指渲染的时候要调用的方法名字-->
                        <a render-fun="getHref" render-key="list.travel.id" data-url="/travelContent.html?id=" >
                            <div class="aui-layNews-time" render-html="list.createTime"></div>
                            <div class="aui-layNews-text">
                                <div class="aui-layNews-info b-line" render-html="list.content"></div>
                                <br/>
                                <span render-html="list.travel.title" style="color: deeppink;width: 50px" ></span>
                                <div class="aui-flex">
                                    <div class="aui-flex-box" style="background-color: #b8daff">点击查看详情</div>
                                </div>
                            </div>
                        </a>


                        <!--<a href="javascript:;">
                            <div class="aui-layNews-time">08月29日 10:38</div>
                            <div class="aui-layNews-text">
                                <div class="aui-layNews-info b-line">
                                    <h2>待支付订单</h2>
                                    <p>您有一条待支付订单</p>
                                    <p>订单号:201828933339008223</p>
                                    <p>请尽快支付,下单后24小时未支付将自动取消!</p>
                                </div>
                                <div class="aui-flex">
                                    <div class="aui-flex-box">查看详情</div>
                                    <div class="aui-layNews-arrow"></div>
                                </div>
                            </div>
                        </a>-->

                    </div>
                </div>
            </div>
        </div>
    </section>
</div>

</body>
</html>
